{extend name="public/common"} {block name="body"}
<title>基本设置</title>
</head>

<style type="text/css">
	.bg-1 {
    background-color: #ffffff !important;
    border-color: #ffffff !important;
}
 .radius:hover{
 	background:#e5e5e5;
 	border-color: #e5e5e5;
 	color: #333;
 }
  .radius1:hover{
 	color: #fff;
	border-color: #66b1ff;
	background-color: #66b1ff;
 }
 span:hover{
 	color: #333;
 }
 .line{
 	position: absolute;
	right: 0;
	top: 13px;
	background: #636363;
	width: 1px;
	height: 14px;
	overflow: hidden;
 }
 .radius{
 	position: relative;
 }
 .btn-warning {
    color: #fff;
    background-color: #409eff;
    border-color: #409eff;
}
</style>

<body>
  <nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i>
    系统管理
    <span class="c-gray en">&gt;</span>
   财务设置
    <span class="c-gray en">&gt;</span>
 充值支付方案
 <span class="c-gray en">&gt;</span>
 {if($ticker==2)}<a href="javascript:;">用户支付开关</a>{/if}
 {if($ticker==1)}<a href="javascript:;">第三方支付方案</a>{/if}
 {if($ticker==0)}<a href="javascript:;">线下支付账户设置</a>{/if}
 <!--{if($ticker==3)}<a href="javascript:;">线上支付方案</a>{/if}-->
    <a class="btn btn-success radius r"
      style="line-height: 1.6em; margin-top: 3px"
      href="javascript:location.replace(location.href);" title="刷新">
      <i class="Hui-iconfont">&#xe68f;</i>
    </a>
  </nav>
  
  <div style="padding:20px;height:30px;">
  	
  	<div class="new_box">

  <div style="height:30px;margin-bottom: 23px;">
    <div style="float:left;height: 40px;width: 100%;background-color: #e5e5e5 !important;border-bottom: 1px solid #e4e7ed;">
        <a class="btn btn-primary radius"  href="{:url('paysetting/payList')}?ticker=2" {if($ticker==2)}style="background:#636363;border-color: #636363;color: #fff;"{/if}>用户支付开关<span class="line">◆</span></a>
        <a class="btn btn-primary radius"  href="{:url('paysetting/payList')}?ticker=0" {if($ticker==0)}style="background:#636363;border-color: #636363;color: #fff;"{/if}>线下支付账户设置<span class="line">◆</span></a>
        <a class="btn btn-primary radius"  href="{:url('paysetting/payList')}?ticker=1" {if($ticker==1)}style="background:#636363;border-color: #636363;color: #fff;"{/if}>第三方支付设置</a>
        <!--<a class="btn btn-primary radius"  href="{:url('paysetting/payList')}?ticker=3" {if($ticker==3)}style="background:#636363;border-color: #636363;color: #fff;"{/if}>第四方支付设置</a>-->
    </div>
  </div>

  {if($ticker == 0)}
  <div style="padding:0;height:30px;">
    <div style="float:left;margin-left:20px;">
      <a class="btn btn-warning radius radius1"  href="{:url('paysetting/addOfflineAccount')}">添加线下收款账户</a>
    </div>
  </div>
  {/if}
  {if($ticker == 2)}
  <div style="padding:0;height:30px;">
      <div style="float:left;margin-left:20px;">
          <a class="btn btn-warning radius radius1"  href="{:url('paysetting/addPayMethod')}">添加支付类型</a>
      </div>
  </div>
  {/if}
 {if($ticker == '1')}
 <div class="text-c" style="padding :20px 0;">
 <div  style="width:80px;height:32px;line-height:32px;padding:0;" class="formControls col-xs-8 col-sm-9">方案：</div>
    <form action="" method="post">
    <div  style="width:217px;" class="formControls col-xs-8 col-sm-9"> 
    	<span class="select-box">
			<select class="select" name="method" id="code">
			<option value="0" selected>全部</option>
			{foreach ($pay as $v)}
				<option value="{$v.id}" {if($method==$v['id'])}selected{/if}>{$v.pay_name}</option>
			{/foreach}
			</select>
		</span> 
	</div>
	<div  style="width:80px;height:32px;line-height:32px;padding:0;" class="formControls col-xs-8 col-sm-9">状态：</div>
	<div  style="width:150px;" class="formControls col-xs-8 col-sm-9" style="margin-left:0;"> 
    	<span class="select-box">
			<select class="select" name="open" id="code">
				<option value="-1">全部</option>
				<option value="1" {if($open=='1')}selected{/if}>开</option>
				<option value="0" {if($open=='0')}selected{/if}>关</option>
			</select>
		</span> 
	</div>
	<div  style="width:80px;" class="formControls col-xs-8 col-sm-9"> 
  <button class="btn btn-primary radius" type="submit">搜索</button>
</div>
</form>
  </div>
  {/if}
  <div class="page-container dataTables_wrapper">
      <div id="tab-system" class="HuiTab">
        <div class="tabCon">
          <div class="mt-20">
            <table
              class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
              <thead>
                <tr class="text-c">
                {if($ticker==0)}
                  <th>方案类型</th>
                  <th>名称</th>
                  <th>所属支付</th>
                  <th>二维码/卡号</th>
                  <th>标识</th>
                  <!--<th>开关</th>-->
                  <th>操作</th>
                 {elseif($ticker==1||$ticker==3) /}
                  <th>序号</th>
                  <th>方案名称</th>
                  <!--<th>等级权限</th>-->
                  <th>开关</th>
                    {if(1==$ticker)}
                        <th>标识</th>
                    {/if}
                  <th>操作</th>
                  {else}
                    <th>方案名称</th>
                    <th>赠送方案</th>
                    <th>顺序</th>
                    <th>开关</th>
                    <th>支付通道列表</th>
                  {/if}
                </tr>
              </thead>
              <tbody>
              {foreach ($xxpay as $v)}
               <tr class="text-c">
           		{if($ticker==0)}
                  <td>
                  {if($v['xx_weixin']=='1' && $v['xx_zhifubao']=='0'&&$v['xx_wangyin']=='0'&&$v['xx_qq']=='0')}微信扫码{/if}
                  {if($v['xx_weixin']=='0' && $v['xx_zhifubao']=='1'&&$v['xx_wangyin']=='0'&&$v['xx_qq']=='0')}支付宝扫码{/if}
                  {if($v['xx_weixin']=='0' && $v['xx_zhifubao']=='0'&&$v['xx_wangyin']=='1'&&$v['xx_qq']=='0')}银联转账{/if}
                  {if($v['xx_weixin']=='0' && $v['xx_zhifubao']=='0'&&$v['xx_wangyin']=='0'&&$v['xx_qq']=='1')}QQ扫码{/if}
                  </td>
                  <td>{if($v['xx_weixin']=='0' && $v['xx_zhifubao']=='0' && $v['xx_qq']=='0' &&$v['xx_wangyin']=='1')}{$v.xx_bankren}{else/}{$v.xx_name}{/if}</td>
                   <td>
                       <select onchange="checkMethod(this,{$v['id']},3)">
                           <option value="0">关闭</option>
                           {foreach $paymethod as $key=>$val}
                           <option value="{$key}" {if( $key==$v['method_id'] )} selected {/if}>{$val}</option>
                           {/foreach}
                       </select>
                   </td>
                   <td>
                       {if($v['xx_weixin']=='0' && $v['xx_zhifubao']=='0' && $v['xx_qq']=='0' &&$v['xx_wangyin']=='1')}
                            {$v.xx_bankno}
                       {else/}
                            <img style="height: 40px;" src="../../static/attachment/{$v.xx_erweima}">
                       {/if}
                   </td>
                   <!--<td>-->
                      <!--<span >{$v['status']==1?'已开启':'已关闭'}</span>&nbsp;&nbsp;&nbsp;&nbsp;-->
                      <!--<a style="color:red;cursor:pointer;width:25px;background-color: #cccccc;padding:0 5px;border-radius: 5px;" class="open_off" data-id="{$v.id}" data-status="{$v['status']}">{if($v['status']==1)}关{else/}开{/if}</a>-->
                    <!--</td>-->
                   <td>{$v.label}</td>
                   <td class="f-14 td-manage" style="width:75px;">
					   <!--<a href="javascript:if(confirm('是否确认操作？')){window.location.href='{:url('paysetting/DelChongzhi')}?zfid={$v.id}'}"  >删除</a>-->
					  <a href=" {if($v['xx_weixin']=='1')} {:url('paysetting/cz_fa_list')}?zfid={$v.id} {elseif('1'==$v['xx_zhifubao'])} {:url('paysetting/cz_fa_new')}?zfid={$v.id} {elseif('1'==$v['xx_wangyin'])} {:url('paysetting/cz_dsf_list')}?zfid={$v.id} {elseif('1'==$v['xx_qq'])} {:url('paysetting/cz_qq')}?zfid={$v.id} {/if}"  >编辑</a>
                  </td>
                   {elseif($ticker==1) /}
                      <td>{$v.id}</td>
                      <td>{$v.pay_name}</td>
                      <!--<td><a href="javascript:;" onclick="Jurisdiction('等级权限','{:url('paysetting/jurisdiction')}?id={$v.id}')"> <i class="Hui-iconfont">&#xe62e;</i></a></td>-->
                      <td>
                          <span >{$v['open']==1?'已开启':'已关闭'}</span>&nbsp;&nbsp;&nbsp;&nbsp;
                          <a style="color:red;cursor:pointer;width:25px;background-color: #cccccc;padding:0 5px;border-radius: 5px;" class="open" id="open_{$v.id}">{if($v['open']==1)}关{else/}开{/if}</a>
                      </td>
                       <td>{$v['label']}</td>
                      <td><a href="javascript:pay_detail('支付方式列表','{:url(\'Paysetting/payDetail\')}?id={$v.id}');" style='display:block; width:100px; margin:0 auto; text-align:center; background:none; border:none; cursor:pointer; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; word-break:keep-all;'>查看详细</a></td>
                   {elseif($ticker==3) /}
                       <td>{$v.id}</td>
                       <td>{$v.pay_name}</td>
                       <!--<td><a href="javascript:;" onclick="Jurisdiction('等级权限','{:url('paysetting/jurisdiction')}?id={$v.id}')"> <i class="Hui-iconfont">&#xe62e;</i></a></td>-->
                       <td>
                          <span >{$v['open']==1?'已开启':'已关闭'}</span>&nbsp;&nbsp;&nbsp;&nbsp;
                          <a style="color:red;cursor:pointer;width:25px;background-color: #cccccc;padding:0 5px;border-radius: 5px;" class="open" id="open_{$v.id}">{if($v['open']==1)}关{else/}开{/if}</a>
                        </td>
                       <td>
                           <a href="javascript:pay_account('二维码账户列表','{:url(\'Paysetting/payAccount\')}?id={$v.id}');" style=' width:100px;  text-align:center; background:none; border:none; cursor:pointer;'>查看账户</a>
                           <a href="javascript:pay_account('添加收款账户','{:url(\'Paysetting/addCodeAccount\')}?id={$v.id}');" style='width:100px; text-align:center; background:none; border:none; cursor:pointer;'>添加收款账户</a>
                       </td>
                 {else}
                    <td>{$v.name}</td>
                    <td>
                        {if($v.money>0)}
                            {if(0==$v.method)}
                                {$v.money}元
                            {else/}
                                {$v.money}%
                            {/if}
                        {else/}
                            无
                        {/if}
                    </td>
                    <td>{$v.seq}</td>
                    <td>
                        <span >{$v['status']==0?'已关闭':'已开启'}</span>&nbsp;&nbsp;&nbsp;&nbsp;              
                        <a style="color:red;cursor:pointer;width:25px;background-color: #cccccc;padding:0 5px;border-radius: 5px;" class="open_m" id="openm_{$v.id}" data-id="{$v.id}" href="javascript:;">{if($v['status']==0)}开{else/}关{/if}</a></td>
                    <td>
                        <a href="javascript:pay_detail('','{:url(\'Paysetting/addPayMethod\')}?id={$v.id}');" style='width:100px; margin:0 auto; text-align:center; background:none; border:none; cursor:pointer; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; word-break:keep-all;'>编辑</a> |
                        <a href="javascript:pay_detail('','{:url(\'Paysetting/methodList\')}?id={$v.id}');" style='width:100px; margin:0 auto; text-align:center; background:none; border:none; cursor:pointer; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; word-break:keep-all;'>列表</a>
                    </td>
       			  {/if}
                </tr>
			{/foreach}
              </tbody>
            </table>
          </div>
        </div>
      </div>
      <div class="dataTables_paginate paging_simple_numbers" style="width:100%;">
            <span style="float:right;margin-left:-2px;">总共{$xxpay->lastPage()}页  当前第{$xxpay->currentPage()}页 ，共{$xxpay->total()}条</span>
            <div style="float:left;">{$xxpay->render()}</div>
    </div>
  </div>
  
  </div>
</div>
{/block}

{block name="js"}
  <script type="text/javascript" src="__SYSMET__/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
  <script type="text/javascript">
    $(function() {
      $('.skin-minimal input').iCheck({
        checkboxClass : 'icheckbox-blue',
        radioClass : 'iradio-blue',
        increaseArea : '20%'
      });
      $("#tab-system").Huitab({
        index : 0
      });
    });
    
</script>
<script type="text/javascript">
function Jurisdiction(title,url,w,h){
	layer_show(title,url,w,500);
}

function pay_detail(title,url){
	var index = layer.open({
		type: 2,
		title: title,
		area: ['90%', '90%'],
		content: url
	});
}

function pay_account(title,url){
	var index = layer.open({
		type: 2,
		title: title,
		area: ['90%', '90%'],
		content: url
	});
}
$('.open_m').click(function(){
    var id = $(this).data('id');
    var status = $(this).html();
    $.ajax({
        type : "post",
        url : "{:url('paysetting/updateOpenM')}",
        data : {"open":status,"id":id},
        success: function (data) {
            if(data=='1') {
                if(status=='开'){
                    $('#openm_'+id).html('关');
                    $('#openm_'+id).prev().html('已开启');
//                    location.replace(location.href);
                }else{
                    $('#openm_'+id).html('开');
                    $('#openm_'+id).prev().html('已关闭');
//                    location.replace(location.href);
                }
            } else {
                layer.msg('更新失败', {icon: 5});
                return false;
            }
        }
    });
});
$(".open").click(function(){
	var open = $(this).attr('id');
	var status = $("#"+open).html();
	var tid = open.substr(5);
	$.ajax({
        type : "post",
        url : "{:url('paysetting/updateOpen')}",
        data : {"open":status,"uid":tid},
        success: function (data) {
        	if(data=='1') {
        		if(status=='开'){
        			$("#"+open).html('关');
                    $("#"+open).prev().html('已开启');
        		}else{
        			$("#"+open).html('开');
                    $("#"+open).prev().html('已关闭');
        		}
        	} else {
        		layer.msg('更新失败', {icon: 5});
        		return false;
        	}
        }
    });
});
$('.open_off').click(function(){
    var status = $(this).data('status');
    var id = $(this).data('id');
    var obj = this;
    $.ajax({
        type : "post",
        url : "{:url('paysetting/updateOff')}",
        data : {"id":id,"status":status},
        success: function (data) {
            if( 1==parseInt(data)) {
                if( status == 1 ){
                    $(obj).html('关');
                    $(obj).data('status',0);
                     location.replace(location.href);
                }else{
                    $(obj).html('开');
                    $(obj).data('status',1);
                     location.replace(location.href);
                }
            } else {
                layer.msg('更新失败', {icon: 5});
                return false;
            }
        }
    });
});
function checkMethod(obj,id,type){
    var select = $(obj).find("option:selected").val();
    $.ajax({
        type : "post",
        url : "{:url('paysetting/checkMethod')}",
        data : {"id":id,"value":select,"type":type},
        success: function (data) {
            data = JSON.parse(data);
            var icon = 5;
            if( 1==parseInt(data.status) ){
                icon = 1;
            }
            layer.msg(data.msg, {icon: icon});
        }
    });
}

</script>
{/block}
